package com.example.qnotes;

import java.util.List;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import br.ufc.cloud.qnotes.ui.MainActivity;
import br.ufc.cloud.qnotes.ui.Nota;

public class ListaNotasActivity extends Activity {
	
	List<Nota> notas;
	ListView listview;
	MainActivity nota;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_lista_notas);
		listview = (ListView)findViewById(R.id.listview_notas);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.lista_notas, menu);
		return true;
	}
	
	private class MyAsyncTask extends AsyncTask<Void, Void, Nota[]>{

		@Override
		protected Nota[] doInBackground(Void... params) {
			// TODO Auto-generated method stub
			notas = nota.getNotas();
			return null;
		}
		
		
		@Override
		protected void onPostExecute(Nota[] result) {
			// TODO Auto-generated method stub
			ArrayAdapter<Nota> notes = new ArrayAdapter<Nota>(ListaNotasActivity.this, android.R.layout.simple_list_item_1, notas);
			listview.setAdapter(notes);
			super.onPostExecute(result);
		}
		
	}

}
